using System;
using System.Collections.Generic;
using System.Text;

using System.Diagnostics;
using Microsoft.SharePoint;

namespace TweakSP.Deployment
{
    public class AdminFeatureReceiver : Microsoft.SharePoint.SPFeatureReceiver
    {
        private const string TWEAKSP_HOME_URL = "/_admin/TweakSP_Main.aspx";

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            Debug.WriteLine("AdminFeatureReceiver:FeatureActivated");
            
            SPWeb web = (SPWeb)properties.Feature.Parent;

            DeploymentUtilities.AddAdminNavigationNode(web.Url, "TweakSP", TWEAKSP_HOME_URL);
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            Debug.WriteLine("AdminFeatureReceiver:FeatureDeactivating");
            string centralAdminUrl = DeploymentUtilities.GetCentralAdminWebUrl();
            DeploymentUtilities.RemoveAdminNavigationNode(centralAdminUrl, TWEAKSP_HOME_URL);
        }

        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {
        }

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {
            Debug.WriteLine("AdminFeatureReceiver:FeatureUninstalling");
            SPWeb web = (SPWeb)properties.Feature.Parent;

            DeploymentUtilities.DeleteTimerJob(web.Url, TweakSPInstallationJob.JOB_NAME);
        }





    }
}
